<template>
  <div class="logo">
    <router-link to="/" :title="title">
      <img :class="imgClassName" :src="imgUrl" />
    </router-link>
  </div>
</template>

<script>
/**
 * @Author: 焦质晔
 * @Date: 2019-06-20 10:00:00
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-11-20 11:37:17
 **/
const logoEp = require('@/assets/img/logoPk.png');
const logo = require('@/assets/img/logo-shuban.jpg');

export default {
  name: 'Logo',
  props: {
    title: {
      type: String,
      default: ''
    },
    collapsed: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      isInitial: true
    };
  },
  computed: {
    imgUrl() {
      return !this.collapsed ? logoEp : logo;
    },
    imgClassName() {
      const res = !this.collapsed ? `img1` : `img2`;
      return this.isInitial ? `${res} none` : res;
    }
  },
  watch: {
    collapsed(val) {
      this.isInitial = false;
    }
  }
};
</script>

<style lang="less" scoped>
.logo {
  line-height: 58px;
  background-color: @logoBgColor;
  overflow: hidden;
  .router-link-active {
    display: block;
    img {
      display: inline-block;
      vertical-align: middle;
    }
    .img1 {
      width: 100%;
      animation: show 0.3s ease both;
    }
    .img2 {
      width: 100%;
      // animation: hide 0.3s ease both;
    }
    .none {
      animation: none;
    }
  }
}
@keyframes show {
  0% {
    opacity: 0;
    width: 40px;
  }
  100% {
    opacity: 1;
    width: 100%;
  }
}
@keyframes hide {
  0% {
    opacity: 0;
    width: 100%;
  }
  100% {
    opacity: 1;
    width: 40px;
  }
}
</style>
